//引入路由组件
import Home from '@/views/Home'
import Search from '@/views/Search'
import Login from '@/views/Login'
import Register from '@/views/Register'
//引入详情组件
import Detail from '@/views/Detail'
//引入加入购物车成功组件
import AddCartSuccess from '@/views/AddCartSuccess'
//引入购物车的组件
import ShopCart from '@/views/ShopCart'
//路由配置信息
//对外暴露
export default [
    {
        //重定向，在项目跑起来的时候，访问/，立马让他定向到首页
        path: '/',
        name: 'Home',
        redirect: "/home",
    },
    {
        path: '/home',
        name: "Home",
        component: Home,
        meta: { show: true }
    },
    {
        path: '/search/:keyword?',
        name: "Search",
        component: Search,
        meta: { show: true },
        //路由组件能不能传递props数据
        //布尔值写法：params
        // props: true
        // 2.对象写法,额外的给路由组件传递一些props
        // props: { a: 1, b: 2 }
        // 3.函数写法：可以params参数，query参数，通过props传递给路由组件
        props: ($route) => {
            return { keyword: $route.params.keyword, k: $route.query.k }
        }
    },
    {
        path: '/login',
        name: "Login",
        component: Login,
        meta: { show: false }
    },
    {
        path: '/register',
        name: "Register",
        component: Register,
        meta: { show: false }
    },
    {
        path: '/detail/:skuid',
        //占位符：传参
        name: 'Detail',
        component: Detail,
        meta: { show: false }
    },
    {
        path: '/addcartsuccess',
        name: 'AddCartSuccess',
        component: AddCartSuccess,
        meta: { show: false }
    },
    {
        path: '/shopcart',
        name: 'ShopCart',
        component: ShopCart,
        meta: { show: false }
    }
]